package cz.uhk.gui.cellRenderers;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

import cz.uhk.domain.Bludiste;

public class BludisteCellRenderer extends DefaultTableCellRenderer{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -2006447906339113463L;
	Bludiste bludiste;
	Color brown = new Color(200, 90, 27);
	
	public BludisteCellRenderer(Bludiste bludiste){
		super();
		this.bludiste = bludiste;
	}

	@Override
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		
		Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        
		
		if(bludiste.getReprezentace()[row][column] == 1){//obarvi steny
			c.setBackground(Color.BLACK);
			c.setForeground(Color.BLACK);
		}
		else if(bludiste.getReprezentace()[row][column] == 0){//obarvy prazdne mistnosti
			c.setBackground(Color.WHITE);
			c.setForeground(Color.WHITE);
		}
		else if(bludiste.getReprezentace()[row][column] == 2){//obarvy dvere
			c.setBackground(Color.CYAN);
			c.setForeground(Color.CYAN);
		}
		else if(bludiste.getReprezentace()[row][column] == 3){//obarvy mys
			c.setBackground(Color.GRAY);
			c.setForeground(Color.GRAY);
		}
		else if(bludiste.getReprezentace()[row][column] == 4){//obarvy syr
			c.setBackground(Color.YELLOW);
			c.setForeground(Color.YELLOW);
		}
		else if(bludiste.getReprezentace()[row][column] > 4){//obarvy syr
			c.setBackground(Color.WHITE);
			c.setForeground(Color.WHITE);
		}
        
		
        return c;
	}
	
	

}
